<template>
  <view style="height: 100%">
    <poster-share v-if="flag" :canvasInfo="canvasInfo" />
    <!-- 登录组件 -->
    <UserLoginModal ref="openLogin"></UserLoginModal>
  </view>
</template>

<script>
import { mapState } from "vuex";
import PosterShare from "@/CarModel/components/PosterShare";
export default {
  name: "CarModleShare",
  components: {
    PosterShare,
  },
  data() {
    return {
      flag: false,
      canvasInfo: {},
    };
  },
  onLoad(options) {
    let { headImg, vesName, codeUrl, vemVid, vemId } = JSON.parse(decodeURIComponent(options.item))
    this.canvasInfo.imageHead = headImg
    this.canvasInfo.textHead = vesName
    this.canvasInfo.imageBody = codeUrl
    this.shareMixin.title = vesName;
    this.shareMixin.path = `/CarModel/CarDetail`;
    this.shareMixin.query = `vemVid=${vemVid}&vemId=${vemId}`;
    // 是否登录
    if (Object.keys(this.loginInfo).length === 0) {
      this.$refs.openLogin.isShow();
      return false;
    }
  },
  methods: {},
  computed: {
    ...mapState(["loginInfo", 'brandInfo']),
  },
  watch: {
    'loginInfo': {
      handler(newVal) {
        if (Object.keys(newVal).length === 0) return
        let { avatarUrl, nickName } = newVal
        this.canvasInfo.headImg = avatarUrl
        this.canvasInfo.titleRank = nickName
        this.flag = true
      },
      deep: true,
      immediate: true
    }
  },
};
</script>
